<?php
namespace app\manage\controller;
use think\Request;
use app\manage\controller\Base;
use app\manage\model\Admin as Madmin;

/**
 * @title admin 管理用户接口|[管理端]
 * @description 与管理用户有关的信息
 */
 
class Admin extends Base
{
	
	/**
     * @title admin/login 管理用户登录系统后台 POST
     * @description 说明：依据  用户名+密码登录 | 手机号+密码登录 |
	 * openid 密码 注意加密存储
	 * @author 虾哥@2424899422@qq.com
	 * @url admin/create/
	 * @Turl manage/admin/create
	 
	 * @param name:tel type:strying require:1 default:null other: desc: 手机号码与系统不能重复
	 * @param name:captcha type:strying require:1 default:null other: desc:验证码
	 * @param name:openid type:strying require:1 default:1 other: desc:openid
	 * @param name:pass_word type:int require:0 default:1 other: desc:密码
	 * @param name:login_name type:int require:0 default:0 other: desc:登录名称与系统不能重复

	 * @return lists:返回影响行数@
     * @lists nums:0失败|大于0为新增行数
     * 
     */
    public function login() {
	   $data = Request::instance()->post();
	   $return = array('code' => 0, 'message' => 'create admin success !', 'data' => array());
	   $data['create_time'] = time();
	   $data = Madmin::cartAdd($data);
	   if (empty($data)) {
			$return['code'] = 1;
			$return['message'] = 'create admin failed !';
			$return['data']['nums'] = 0;
			return $return;
		}
		$return['data']['nums'] = $data;
		return json($return);	
	}
	
	/**
     * @title admin/logout 管理用户退出后台 GET
     * @description 说明：管理用户退出后台 
	 * @author 虾哥@2424899422@qq.com
	 * @url admin/logout/
	 * @Turl manage/admin/logout

	 * @return lists:返回影响行数@
     * @lists nums:0失败|大于0为新增行数
     * 
     */
    public function logout() {
	   $data = Request::instance()->post();
	   $return = array('code' => 0, 'message' => 'create admin success !', 'data' => array());
	   $data['create_time'] = time();
	   $data = Madmin::cartAdd($data);
	   if (empty($data)) {
			$return['code'] = 1;
			$return['message'] = 'create admin failed !';
			$return['data']['nums'] = 0;
			return $return;
		}
		$return['data']['nums'] = $data;
		return json($return);	
	}
	
	/**
     * @title admin/update 管理用户修改相关个人信息
     * @description 说明： 管理用户修改相关个人信息
	 * @author 虾哥@2424899422@qq.com
	 * @url admin/update/
	 * @Turl manage/admin/update

	 * @return lists:返回影响行数@
     * @lists nums:0失败|大于0为新增行数
     * 
     */
    public function update() {
	   $data = Request::instance()->post();
	   $return = array('code' => 0, 'message' => 'create admin success !', 'data' => array());
	   $data['create_time'] = time();
	   $data = Madmin::cartAdd($data);
	   if (empty($data)) {
			$return['code'] = 1;
			$return['message'] = 'create admin failed !';
			$return['data']['nums'] = 0;
			return $return;
		}
		$return['data']['nums'] = $data;
		return json($return);	
	}
	

}
